package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("products/product")
public @caption("产品余额") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("product") class Product implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
		
	
		
	private @caption("编号") @column("id")    @primary  @notnull  @note("  ") Long id;// 主键 非空     
			
 			
 			
 		
	
		
	private @caption("商品名") @column("name") @like    @notnull  @note("  ") String name;// 非空     
			
 			
 			
 		
	
		
	private @caption("品牌信息") @column("merchant")      @relate("$merchant") @RelateClass(Merchant.class)  @note("  ") Long merchant;//     
			
 	private transient Merchant $merchant;//关联对象[品牌信息]
 			
 			
 			
 		
	
		
	private @caption("用户编号") @column("uid") @like    @notnull  @note("  ") String uid;// 非空     
			
 			
 			
 		
	
		
	private transient @caption("会员名称") @column("nick_name") @like     @note("  ") String nickName;//     
			
 			
 			
 		
	
		
	private @caption("所属会员") @column("member")   @hidden    @relate("$member") @RelateClass(Member.class)  @note("  ") Long member;//     
			
 	private transient Member $member;//关联对象[会员信息]
 			
 			
 			
 		
	
		
	private @caption("商品信息") @column("commodity")      @relate("$commodity") @RelateClass(Commodity.class)  @note("  ") Long commodity;//     
			
 	private transient Commodity $commodity;//关联对象[商品信息]
 			
 			
 			
 		
	
		
	private @caption("价格") @column("p_price")      @note("  ") Double pPrice;//     
			
 			
 			
 		
	
		
	private @caption("单位") @column("p_unit")      @note("  ") String pUnit;//     
			
 			
 			
 		
	
		
	private @caption("商品图") @column("img")   @hidden    @note("  ") String img;//     
			
 			
 			
 		
	
		
	private @caption("数量") @column("number")      @note("  ") Integer number;//     
			
 			
 			
 		
	
		
	private @caption("限制") @column("p_limit")   @hidden    @note("  ") Integer pLimit;//     
			
 			
 			
 		
	
		
	private @caption("规格属性") @column("attribute") @like     @note("  ") String attribute;//     
			
 			
 			
 		
	
		
	private @caption("预留字段") @column("count")   @hidden    @note("  ") Integer count;//     
			
 			
 			
 		
	
		
	private @caption("来源描述") @column("descr") @like  @hidden    @note("  ") String descr;//     
			
 			
 			
 		
	
		
	private @caption("有效期") @column("p_term_validity")      @note("  ") Date pTermValidity;//     
			
 			
 			
 		
	
		
	private @caption("修改时间") @column("update_time")     @notnull  @note("  ") Date updateTime;// 非空     
			
 			
 			
 		
	
		
	private @caption("添加时间") @column("add_time")     @notnull  @note("  ") Date addTime;// 非空     
			
 			
 			
 		
	
		
	private @caption("状态") @column("status")     @notnull  @note(" 1:正常 0:无效  ") Short status;// 非空 1:正常 0:无效     
			
 			
 			
 		
	
	 
	//默认构造函数
	public Product(){ 
	
	}
	
	//主键构造函数
	public Product(Long id){
		this.id = id;
	}
	
	/**所有字段构造函数 
	 Product(
	 	Utils.getString("")//商品名 [非空]
	 	,Utils.getLong("")//品牌信息
	 	,Utils.getString("")//用户编号 [非空]
	 	,Utils.getLong("")//所属会员
	 	,Utils.getLong("")//商品信息
	 	,Utils.getDouble("price")//价格
	 	,Utils.getString("unit")//单位
	 	,Utils.getString("")//商品图
	 	,Utils.getInteger("")//数量
	 	,Utils.getInteger("limit")//限制
	 	,Utils.getString("")//规格属性
	 	,Utils.getInteger("")//预留字段
	 	,Utils.getString("")//来源描述
	 	,Utils.getDate("termValidity")//有效期
	 	,Utils.getDate("time")//修改时间 [非空]
	 	,Utils.getDate("time")//添加时间 [非空]
	 	,Utils.getShort("")//状态 [非空]
	 )
	**/
	public Product(String name,Long merchant,String uid,Long member,Long commodity,Double pPrice,String pUnit,String img,Integer number,Integer pLimit,String attribute,Integer count,String descr,Date pTermValidity,Date updateTime,Date addTime,Short status){
		
			
			
		this.name=name;
		
			
		this.merchant=merchant;
		
			
		this.uid=uid;
		
			
			
		this.member=member;
		
			
		this.commodity=commodity;
		
			
		this.pPrice=pPrice;
		
			
		this.pUnit=pUnit;
		
			
		this.img=img;
		
			
		this.number=number;
		
			
		this.pLimit=pLimit;
		
			
		this.attribute=attribute;
		
			
		this.count=count;
		
			
		this.descr=descr;
		
			
		this.pTermValidity=pTermValidity;
		
			
		this.updateTime=updateTime;
		
			
		this.addTime=addTime;
		
			
		this.status=status;
		
	}
	
	//设置非空字段
	public Product setNotNull(String name,String uid,Date updateTime,Date addTime,Short status){
		
			
			
		this.name=name;
		
			
			
		this.uid=uid;
		
			
			
			
			
			
			
			
			
			
			
			
			
			
		this.updateTime=updateTime;
		
			
		this.addTime=addTime;
		
			
		this.status=status;
		
		return this;
	}
	
	
		
	/** 编号 [非空]       **/
	public Product id(Long id){
		this.id = id;
		this.setSeted(F.id);
		return this;
	}
	
		
	/** 商品名 [非空]       **/
	public Product name(String name){
		this.name = name;
		this.setSeted(F.name);
		return this;
	}
	
		
	/** 品牌信息  [Merchant]      **/
	public Product merchant(Long merchant){
		this.merchant = merchant;
		this.setSeted(F.merchant);
		return this;
	}
	
		
	/** 用户编号 [非空]       **/
	public Product uid(String uid){
		this.uid = uid;
		this.setSeted(F.uid);
		return this;
	}
	
		
		
	/** 所属会员  [Member]      **/
	public Product member(Long member){
		this.member = member;
		this.setSeted(F.member);
		return this;
	}
	
		
	/** 商品信息  [Commodity]      **/
	public Product commodity(Long commodity){
		this.commodity = commodity;
		this.setSeted(F.commodity);
		return this;
	}
	
		
	/** 价格        **/
	public Product pPrice(Double pPrice){
		this.pPrice = pPrice;
		this.setSeted(F.pPrice);
		return this;
	}
	
		
	/** 单位        **/
	public Product pUnit(String pUnit){
		this.pUnit = pUnit;
		this.setSeted(F.pUnit);
		return this;
	}
	
		
	/** 商品图        **/
	public Product img(String img){
		this.img = img;
		this.setSeted(F.img);
		return this;
	}
	
		
	/** 数量        **/
	public Product number(Integer number){
		this.number = number;
		this.setSeted(F.number);
		return this;
	}
	
		
	/** 限制        **/
	public Product pLimit(Integer pLimit){
		this.pLimit = pLimit;
		this.setSeted(F.pLimit);
		return this;
	}
	
		
	/** 规格属性        **/
	public Product attribute(String attribute){
		this.attribute = attribute;
		this.setSeted(F.attribute);
		return this;
	}
	
		
	/** 预留字段        **/
	public Product count(Integer count){
		this.count = count;
		this.setSeted(F.count);
		return this;
	}
	
		
	/** 来源描述        **/
	public Product descr(String descr){
		this.descr = descr;
		this.setSeted(F.descr);
		return this;
	}
	
		
	/** 有效期        **/
	public Product pTermValidity(Date pTermValidity){
		this.pTermValidity = pTermValidity;
		this.setSeted(F.pTermValidity);
		return this;
	}
	
		
	/** 修改时间 [非空]       **/
	public Product updateTime(Date updateTime){
		this.updateTime = updateTime;
		this.setSeted(F.updateTime);
		return this;
	}
	
		
	/** 添加时间 [非空]       **/
	public Product addTime(Date addTime){
		this.addTime = addTime;
		this.setSeted(F.addTime);
		return this;
	}
	
		
	/** 状态 [非空]   1:正常 0:无效     **/
	public Product status(Short status){
		this.status = status;
		this.setSeted(F.status);
		return this;
	}
	
	
	
	/**
	* 克隆对象
	**/
	public Product clone(){
		Product clone = new Product();
		
			
			
		clone.name=this.name;
		
			
		clone.merchant=this.merchant;
		
			
		clone.uid=this.uid;
		
			
			
		clone.member=this.member;
		
			
		clone.commodity=this.commodity;
		
			
		clone.pPrice=this.pPrice;
		
			
		clone.pUnit=this.pUnit;
		
			
		clone.img=this.img;
		
			
		clone.number=this.number;
		
			
		clone.pLimit=this.pLimit;
		
			
		clone.attribute=this.attribute;
		
			
		clone.count=this.count;
		
			
		clone.descr=this.descr;
		
			
		clone.pTermValidity=this.pTermValidity;
		
			
		clone.updateTime=this.updateTime;
		
			
		clone.addTime=this.addTime;
		
			
		clone.status=this.status;
		
		return clone;
	}
	
	
	
	
	
	/**
	 * 根据ID取产品余额
	 * @param id
	 * @return
	 */
	public static @api Product get(Long id){		
		return getProductById(id);
	}
	
	
	
	/**
	 * 获取所有产品余额
	 * @return
	 */
	public static @api List<Product> list(Map params,Integer size){
		return getProductList(params,size);
	}
	/**
	 * 获取产品余额分页
	 * @return
	 */
	public static @api Page<Product> page(Integer page,Integer size,Map params){
		return getProductPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取产品余额
	 * @param params
	 * @return
	 */
	public static @api Product Get(Map params){
		return getProduct(params);
	}
	/**
	 * 获取产品余额数
	 * @return
	 */
	public static @api Long count(Map params){
		return getProductCount(params);
	}
	/**
	 * 获取产品余额数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getProductEval(eval,params);
	}
	
	
	/**
	 * 获取产品余额图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getProductStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取产品余额图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getProductStats(params,sumKey,groupKey,dateType);
	}
	
	
	/**
	 * 根据ID取产品余额
	 * @param id
	 * @return
	 */
	public static @api Product getProductById(Long id){		
		return getProductDao().getProductById(id);
	}
	
	
	
	
	/**
	 * 根据ID取产品余额的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			
			return null;
			
		}
		String value = null;
				
		if(value==null){
			Product product = get(id);
			if(product!=null){
				String strValue = product.getId$();
				
				
				value = strValue;
			}else{
				
				value = "{"+id+"}";
			}
		}
		
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getId$();
		
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询产品余额对象
	 * @return
	 */
	public static @api Product find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("id", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return Product.getProduct(params);
	}
	
	
	/**
	 * 根据关键字查询产品余额
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("id", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		
		
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<Product> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(Product product:list){
			Map map = new HashMap();
			map.put("key",product.getId().toString());
			map.put("value", Utils.js(product.getKeyValue()));
			if(bObject==true)
				map.put("object",product);
			result.add(map);
		}
		
		
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有产品余额
	 * @return
	 */
	public static @api List<Product> getProductList(Map params,Integer size){
		return getProductDao().getProductList(params,0,size);
	}
	
	/**
	 * 获取产品余额分页
	 * @return
	 */
	public static @api Page<Product> getProductPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getProductDao().getProductPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取产品余额
	 * @param params
	 * @return
	 */
	public static @api Product getProduct(Map params){
		return getProductDao().getProduct(params);
	}
	
	/**
	 * 保存一个产品余额
	 * @param product
	 * @return
	 */
	public static @api Product saveProduct(Product product){
		return getProductDao().saveProduct(product);
	}
	
	/**
	 * 根据条件更新产品余额
	 * @param values
	 * @param params
	 */
	public static @api int updateProductByConfirm(Map values, Map params){
		return getProductDao().updateProductByConfirm(values,params);
	}
	
	/**
	 * 修改一个产品余额
	 * @param product
	 * @return
	 */
	public static @api int updateProduct(Product product){
		return getProductDao().updateProduct(product);
	}
	
	/**
	 * 更新产品余额非空字段
	 * @param product
	 */
	public static @api int updateProduct$NotNull(Product product){
		return getProductDao().updateProduct$NotNull(product);
	}
	
	/**
	 * 获取产品余额数
	 * @return
	 */
	public static @api Long getProductCount(Map params){
		return getProductDao().getProductCount(params);
	}
		
		
	/**
	 * 获取产品余额自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getProductEval(String eval,Map params){
		return getProductDao().getProductEval(eval,params);
	}
	
	
	/**
	 * 获取产品余额图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getProductStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getProductDao().getProductStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = Product.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(Product.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateProduct(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getProductDao().updateProductByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteProduct(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getProductDao().deleteProductByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		
		getProductDao().removeProductById(id);
		
	}
	
	
	/**
	 * 保存产品余额对象
	 * @param params
	 * @return
	 */
	public Product save(){
		if(this.getId()!=null)
			getProductDao().updateProduct(this);
		else
			return getProductDao().saveProduct(this);
		return this;
	}
	
	
	/**
	 * 更新产品余额对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getProductDao().updateProduct$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		
		if(Utils.equals(Utils.config("logic_delete"),"true"))
			getProductDao().removeProductById(this.getId());
		else
		
			getProductDao().deleteProductById(this.getId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getProductDao().executeTransaction(function);
	}

	
	
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getId(){
		
		if(this.id!=null){
			return this.id;
		}
		
		return this.id;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getId$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getId());
	 
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setId$(String strValue){
		if(Utils.empty(strValue)){
			this.id=null;
			return;
		}
	
	
	 	this.id=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setId(Long id){
		this.id = id;
		
		this.setSeted(F.id);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************商品名**********************************/	
	/**
	* 商品名 [非空]      
	**/
	public String getName(){
		
		if(this.name!=null){
			return this.name;
		}
		
		return this.name;
	}
	/**
	* 获取商品名格式化(toString)
	**/
	public String getName$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getName());
	 
	 	 return strValue;
	}
	/**
	* 根据商品名反格式化
	**/
	public void setName$(String strValue){
		if(Utils.empty(strValue)){
			this.name=null;
			return;
		}
	
	
	 	this.name=strValue;
	 
	}
	
	/**
	* 商品名 [非空]      
	**/
	public void setName(String name){
		this.name = name;
		
		this.setSeted(F.name);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************品牌信息**********************************/	
	/**
	* 品牌信息  [Merchant]     
	**/
	public Long getMerchant(){
		
		if(this.merchant!=null){
			return this.merchant;
		}
		
		return this.merchant;
	}
	/**
	* 获取品牌信息格式化(toString)
	**/
	public String getMerchant$(){
		String strValue="";
	
	
		 
		if(this.getMerchant()!=null){
			
				strValue+=Utils.string(Merchant.getKeyValue(this.getMerchant()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据品牌信息反格式化
	**/
	public void setMerchant$(String strValue){
		if(Utils.empty(strValue)){
			this.merchant=null;
			return;
		}
	
	
		 
		Merchant item = Merchant.find(strValue);
		if(item!=null){
			
			this.merchant = Utils.parseLong(item.getId());
			
		}
		 
	 
	}
	
	/**
	* 品牌信息  [Merchant]     
	**/
	public void setMerchant(Long merchant){
		this.merchant = merchant;
		
		this.setSeted(F.merchant);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[品牌信息]
	**/	 			
 	public Merchant get$merchant(){
 		if(this.$merchant!=null)
 			return this.$merchant;
 		com.distribute.framework.model.Merchant merchant = null;
		if(this.getMerchant()!=null){
		
 			merchant = Merchant.get(this.getMerchant());
 		
 		}
 		return merchant;
	}
	
 	
	
	
	/*******************************用户编号**********************************/	
	/**
	* 用户编号 [非空]      
	**/
	public String getUid(){
		
		if(this.uid!=null){
			return this.uid;
		}
		
		return this.uid;
	}
	/**
	* 获取用户编号格式化(toString)
	**/
	public String getUid$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getUid());
	 
	 	 return strValue;
	}
	/**
	* 根据用户编号反格式化
	**/
	public void setUid$(String strValue){
		if(Utils.empty(strValue)){
			this.uid=null;
			return;
		}
	
	
	 	this.uid=strValue;
	 
	}
	
	/**
	* 用户编号 [非空]      
	**/
	public void setUid(String uid){
		this.uid = uid;
		
		this.setSeted(F.uid);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************会员名称**********************************/	
	/**
	* 会员名称       
	**/
	public String getNickName(){
		
		if(this.nickName!=null){
			return this.nickName;
		}
		
		Member member = Member.get(this.getMember());
		if(member!=null){
			this.nickName=member.getNickName();
		}
				
		
		return this.nickName;
	}
	/**
	* 获取会员名称格式化(toString)
	**/
	public String getNickName$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getNickName());
	 
	 	 return strValue;
	}
	/**
	* 根据会员名称反格式化
	**/
	public void setNickName$(String strValue){
		if(Utils.empty(strValue)){
			this.nickName=null;
			return;
		}
	
	
	 	this.nickName=strValue;
	 
	}
	
	/**
	* 会员名称       
	**/
	public void setNickName(String nickName){
		this.nickName = nickName;
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************所属会员**********************************/	
	/**
	* 所属会员  [Member]     
	**/
	public Long getMember(){
		
		if(this.member!=null){
			return this.member;
		}
		
		return this.member;
	}
	/**
	* 获取所属会员格式化(toString)
	**/
	public String getMember$(){
		String strValue="";
	
	
		 
		if(this.getMember()!=null){
			
				strValue+=Utils.string(Member.getKeyValue(this.getMember()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据所属会员反格式化
	**/
	public void setMember$(String strValue){
		if(Utils.empty(strValue)){
			this.member=null;
			return;
		}
	
	
		 
		Member item = Member.find(strValue);
		if(item!=null){
			
			this.member = Utils.parseLong(item.getUid());
			
		}
		 
	 
	}
	
	/**
	* 所属会员  [Member]     
	**/
	public void setMember(Long member){
		this.member = member;
		
		this.setSeted(F.member);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[会员信息]
	**/	 			
 	public Member get$member(){
 		if(this.$member!=null)
 			return this.$member;
 		com.distribute.framework.model.Member member = null;
		if(this.getMember()!=null){
		
 			member = Member.get(this.getMember());
 		
 		}
 		return member;
	}
	
 	
	
	
	/*******************************商品信息**********************************/	
	/**
	* 商品信息  [Commodity]     
	**/
	public Long getCommodity(){
		
		if(this.commodity!=null){
			return this.commodity;
		}
		
		return this.commodity;
	}
	/**
	* 获取商品信息格式化(toString)
	**/
	public String getCommodity$(){
		String strValue="";
	
	
		 
		if(this.getCommodity()!=null){
			
				strValue+=Utils.string(Commodity.getKeyValue(this.getCommodity()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据商品信息反格式化
	**/
	public void setCommodity$(String strValue){
		if(Utils.empty(strValue)){
			this.commodity=null;
			return;
		}
	
	
		 
		Commodity item = Commodity.find(strValue);
		if(item!=null){
			
			this.commodity = Utils.parseLong(item.getId());
			
		}
		 
	 
	}
	
	/**
	* 商品信息  [Commodity]     
	**/
	public void setCommodity(Long commodity){
		this.commodity = commodity;
		
		this.setSeted(F.commodity);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[商品信息]
	**/	 			
 	public Commodity get$commodity(){
 		if(this.$commodity!=null)
 			return this.$commodity;
 		com.distribute.framework.model.Commodity commodity = null;
		if(this.getCommodity()!=null){
		
 			commodity = Commodity.get(this.getCommodity());
 		
 		}
 		return commodity;
	}
	
 	
	
	
	/*******************************价格**********************************/	
	/**
	* 价格       
	**/
	public Double getpPrice(){
		
		if(this.pPrice!=null){
			return this.pPrice;
		}
		
		return this.pPrice;
	}
	/**
	* 获取价格格式化(toString)
	**/
	public String getpPrice$(){
		String strValue="";
	
	
			
		 strValue=Utils.string(this.getpPrice());	
			
	 
	 	 return strValue;
	}
	/**
	* 根据价格反格式化
	**/
	public void setpPrice$(String strValue){
		if(Utils.empty(strValue)){
			this.pPrice=null;
			return;
		}
	
	
	 	this.pPrice=Utils.parseDouble(strValue);
	 
	}
	
	/**
	* 价格       
	**/
	public void setpPrice(Double pPrice){
		this.pPrice = pPrice;
		
		this.setSeted(F.pPrice);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************单位**********************************/	
	/**
	* 单位       
	**/
	public String getpUnit(){
		
		if(this.pUnit!=null){
			return this.pUnit;
		}
		
		return this.pUnit;
	}
	/**
	* 获取单位格式化(toString)
	**/
	public String getpUnit$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getpUnit());
	 
	 	 return strValue;
	}
	/**
	* 根据单位反格式化
	**/
	public void setpUnit$(String strValue){
		if(Utils.empty(strValue)){
			this.pUnit=null;
			return;
		}
	
	
	 	this.pUnit=strValue;
	 
	}
	
	/**
	* 单位       
	**/
	public void setpUnit(String pUnit){
		this.pUnit = pUnit;
		
		this.setSeted(F.pUnit);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************商品图**********************************/	
	/**
	* 商品图       
	**/
	public String getImg(){
		
		if(this.img!=null){
			return this.img;
		}
		
		return this.img;
	}
	/**
	* 获取商品图格式化(toString)
	**/
	public String getImg$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getImg());
	 
	 	 return strValue;
	}
	/**
	* 根据商品图反格式化
	**/
	public void setImg$(String strValue){
		if(Utils.empty(strValue)){
			this.img=null;
			return;
		}
	
	
	 	this.img=strValue;
	 
	}
	
	/**
	* 商品图       
	**/
	public void setImg(String img){
		this.img = img;
		
		this.setSeted(F.img);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************数量**********************************/	
	/**
	* 数量       
	**/
	public Integer getNumber(){
		
		if(this.number!=null){
			return this.number;
		}
		
		return this.number;
	}
	/**
	* 获取数量格式化(toString)
	**/
	public String getNumber$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getNumber());
	 
	 	 return strValue;
	}
	/**
	* 根据数量反格式化
	**/
	public void setNumber$(String strValue){
		if(Utils.empty(strValue)){
			this.number=null;
			return;
		}
	
	
	 	this.number=Utils.parseInteger(strValue);
	 
	}
	
	/**
	* 数量       
	**/
	public void setNumber(Integer number){
		this.number = number;
		
		this.setSeted(F.number);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************限制**********************************/	
	/**
	* 限制       
	**/
	public Integer getpLimit(){
		
		if(this.pLimit!=null){
			return this.pLimit;
		}
		
		return this.pLimit;
	}
	/**
	* 获取限制格式化(toString)
	**/
	public String getpLimit$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getpLimit());
	 
	 	 return strValue;
	}
	/**
	* 根据限制反格式化
	**/
	public void setpLimit$(String strValue){
		if(Utils.empty(strValue)){
			this.pLimit=null;
			return;
		}
	
	
	 	this.pLimit=Utils.parseInteger(strValue);
	 
	}
	
	/**
	* 限制       
	**/
	public void setpLimit(Integer pLimit){
		this.pLimit = pLimit;
		
		this.setSeted(F.pLimit);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************规格属性**********************************/	
	/**
	* 规格属性       
	**/
	public String getAttribute(){
		
		if(this.attribute!=null){
			return this.attribute;
		}
		
		return this.attribute;
	}
	/**
	* 获取规格属性格式化(toString)
	**/
	public String getAttribute$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getAttribute());
	 
	 	 return strValue;
	}
	/**
	* 根据规格属性反格式化
	**/
	public void setAttribute$(String strValue){
		if(Utils.empty(strValue)){
			this.attribute=null;
			return;
		}
	
	
		this.attribute=strValue;
	 
	}
	
	/**
	* 规格属性       
	**/
	public void setAttribute(String attribute){
		this.attribute = attribute;
		
		this.setSeted(F.attribute);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************预留字段**********************************/	
	/**
	* 预留字段       
	**/
	public Integer getCount(){
		
		if(this.count!=null){
			return this.count;
		}
		
		return this.count;
	}
	/**
	* 获取预留字段格式化(toString)
	**/
	public String getCount$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getCount());
	 
	 	 return strValue;
	}
	/**
	* 根据预留字段反格式化
	**/
	public void setCount$(String strValue){
		if(Utils.empty(strValue)){
			this.count=null;
			return;
		}
	
	
	 	this.count=Utils.parseInteger(strValue);
	 
	}
	
	/**
	* 预留字段       
	**/
	public void setCount(Integer count){
		this.count = count;
		
		this.setSeted(F.count);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************来源描述**********************************/	
	/**
	* 来源描述       
	**/
	public String getDescr(){
		
		if(this.descr!=null){
			return this.descr;
		}
		
		return this.descr;
	}
	/**
	* 获取来源描述格式化(toString)
	**/
	public String getDescr$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getDescr());
	 
	 	 return strValue;
	}
	/**
	* 根据来源描述反格式化
	**/
	public void setDescr$(String strValue){
		if(Utils.empty(strValue)){
			this.descr=null;
			return;
		}
	
	
		this.descr=strValue;
	 
	}
	
	/**
	* 来源描述       
	**/
	public void setDescr(String descr){
		this.descr = descr;
		
		this.setSeted(F.descr);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************有效期**********************************/	
	/**
	* 有效期       
	**/
	public Date getpTermValidity(){
		
		if(this.pTermValidity!=null){
			return this.pTermValidity;
		}
		
		return this.pTermValidity;
	}
	/**
	* 获取有效期格式化(toString)
	**/
	public String getpTermValidity$(){
		String strValue="";
	
	
	 	 
		 strValue=Utils.string(Utils.date(this.getpTermValidity(),"yyyy-MM-dd"));
		 
	 
	 	 return strValue;
	}
	/**
	* 根据有效期反格式化
	**/
	public void setpTermValidity$(String strValue){
		if(Utils.empty(strValue)){
			this.pTermValidity=null;
			return;
		}
	
	
	 	this.pTermValidity=Utils.date(strValue,"yyyy-MM-dd");
	 
	}
	
	/**
	* 有效期       
	**/
	public void setpTermValidity(Date pTermValidity){
		this.pTermValidity = pTermValidity;
		
		this.setSeted(F.pTermValidity);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************修改时间**********************************/	
	/**
	* 修改时间 [非空]      
	**/
	public Date getUpdateTime(){
		
		if(this.updateTime!=null){
			return this.updateTime;
		}
		
		return this.updateTime;
	}
	/**
	* 获取修改时间格式化(toString)
	**/
	public String getUpdateTime$(){
		String strValue="";
	
	
	 	 
		 strValue=Utils.string(Utils.date(this.getUpdateTime(),"yyyy-MM-dd"));
		 
	 
	 	 return strValue;
	}
	/**
	* 根据修改时间反格式化
	**/
	public void setUpdateTime$(String strValue){
		if(Utils.empty(strValue)){
			this.updateTime=null;
			return;
		}
	
	
	 	this.updateTime=Utils.date(strValue,"yyyy-MM-dd");
	 
	}
	
	/**
	* 修改时间 [非空]      
	**/
	public void setUpdateTime(Date updateTime){
		this.updateTime = updateTime;
		
		this.setSeted(F.updateTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间 [非空]      
	**/
	public Date getAddTime(){
		
		if(this.addTime!=null){
			return this.addTime;
		}
		
		return this.addTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getAddTime$(){
		String strValue="";
	
	
	 	 
		 strValue=Utils.string(Utils.date(this.getAddTime(),"yyyy-MM-dd"));
		 
	 
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.addTime=null;
			return;
		}
	
	
	 	this.addTime=Utils.date(strValue,"yyyy-MM-dd");
	 
	}
	
	/**
	* 添加时间 [非空]      
	**/
	public void setAddTime(Date addTime){
		this.addTime = addTime;
		
		this.setSeted(F.addTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public Short getStatus(){
		
		if(this.status!=null){
			return this.status;
		}
		
		return this.status;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getStatus$(){
		String strValue="";
	
	
		
			
		 if(Utils.equals(Utils.string(this.getStatus()),"1"))
			strValue=Utils.string("正常");		 
			
		 if(Utils.equals(Utils.string(this.getStatus()),"0"))
			strValue=Utils.string("无效");		 
			
		
	 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.status=null;
			return;
		}
	
	
		
			
		 if(Utils.equals(strValue,"正常"))
		 	this.status=Utils.parseShort("1");
			
		 if(Utils.equals(strValue,"无效"))
		 	this.status=Utils.parseShort("0");
			
		
	 
	}
	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public void setStatus(Short status){
		this.status = status;
		
		this.setSeted(F.status);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/	
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(Product.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(Product.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(Product.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(Product.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(Product.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${Product.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${Product.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return Product.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(Product.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${Product.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${Product.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return Product.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(Product.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		
		
			
		
		/** 编号 [非空]       **/
		public M id(Object id){if(proxy)return proxy().id(id);  this.put("id", id);return this;};
	 	/** and id is null */
 		public M idNull(){if(proxy)return proxy().idNull();if(this.get("idNot")==null)this.put("idNot", "");this.put("id", null);return this;};
 		/** not .... */
 		public M idNot(){if(proxy)return proxy().idNot();this.put("idNot", "not");return this;};
 		public M idNotNull(){if(proxy)return proxy().idNotNull();this.put("idNot", "not");this.put("id", null);return this;};
 		public M idNot(Object id){if(proxy)return proxy().idNot(id);this.put("idNot", "not");this.put("id", id);return this;};
	 		
		/** and id <= ? */
		public M idMin(Object min){if(proxy)return proxy().idMin(min);this.put("idMin", min);return this;};
		/** and id >= ? */
		public M idMax(Object max){if(proxy)return proxy().idMax(max);this.put("idMax", max);return this;};
			
			
		public M idIn(String ids){
			if(proxy)return proxy().idIn(ids);  this.put("idIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 商品名 [非空]       **/
		public M name(Object name){if(proxy)return proxy().name(name);  this.put("name", name);return this;};
	 	/** and name is null */
 		public M nameNull(){if(proxy)return proxy().nameNull();if(this.get("nameNot")==null)this.put("nameNot", "");this.put("name", null);return this;};
 		/** not .... */
 		public M nameNot(){if(proxy)return proxy().nameNot();this.put("nameNot", "not");return this;};
 		public M nameNotNull(){if(proxy)return proxy().nameNotNull();this.put("nameNot", "not");this.put("name", null);return this;};
 		public M nameNot(Object name){if(proxy)return proxy().nameNot(name);this.put("nameNot", "not");this.put("name", name);return this;};
	 		
			
		
			
	 	
			
		public M merchant$on(Merchant.M value){if(proxy)return proxy().merchant$on(value);this.put("Merchant", value);value.put("on", "merchant");return this;};
 				
 			
		
		/** 品牌信息  [Merchant]      **/
		public M merchant(Object merchant){if(proxy)return proxy().merchant(merchant);  this.put("merchant", merchant);return this;};
	 	/** and merchant is null */
 		public M merchantNull(){if(proxy)return proxy().merchantNull();if(this.get("merchantNot")==null)this.put("merchantNot", "");this.put("merchant", null);return this;};
 		/** not .... */
 		public M merchantNot(){if(proxy)return proxy().merchantNot();this.put("merchantNot", "not");return this;};
 		public M merchantNotNull(){if(proxy)return proxy().merchantNotNull();this.put("merchantNot", "not");this.put("merchant", null);return this;};
 		public M merchantNot(Object merchant){if(proxy)return proxy().merchantNot(merchant);this.put("merchantNot", "not");this.put("merchant", merchant);return this;};
	 		
			
		public M merchantIn(String ids){
			if(proxy)return proxy().merchantIn(ids);  this.put("merchantIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 用户编号 [非空]       **/
		public M uid(Object uid){if(proxy)return proxy().uid(uid);  this.put("uid", uid);return this;};
	 	/** and uid is null */
 		public M uidNull(){if(proxy)return proxy().uidNull();if(this.get("uidNot")==null)this.put("uidNot", "");this.put("uid", null);return this;};
 		/** not .... */
 		public M uidNot(){if(proxy)return proxy().uidNot();this.put("uidNot", "not");return this;};
 		public M uidNotNull(){if(proxy)return proxy().uidNotNull();this.put("uidNot", "not");this.put("uid", null);return this;};
 		public M uidNot(Object uid){if(proxy)return proxy().uidNot(uid);this.put("uidNot", "not");this.put("uid", uid);return this;};
	 		
			
		
			
	 	
			
		
		/** 会员名称        **/
		public M nickName(Object nickName){if(proxy)return proxy().nickName(nickName);  this.put("nickName", nickName);return this;};
	 	/** and nick_name is null */
 		public M nickNameNull(){if(proxy)return proxy().nickNameNull();if(this.get("nickNameNot")==null)this.put("nickNameNot", "");this.put("nickName", null);return this;};
 		/** not .... */
 		public M nickNameNot(){if(proxy)return proxy().nickNameNot();this.put("nickNameNot", "not");return this;};
 		public M nickNameNotNull(){if(proxy)return proxy().nickNameNotNull();this.put("nickNameNot", "not");this.put("nickName", null);return this;};
 		public M nickNameNot(Object nickName){if(proxy)return proxy().nickNameNot(nickName);this.put("nickNameNot", "not");this.put("nickName", nickName);return this;};
	 		
			
		
			
	 	
			
		public M member$on(Member.M value){if(proxy)return proxy().member$on(value);this.put("Member", value);value.put("on", "member");return this;};
 				
 			
		
		/** 所属会员  [Member]      **/
		public M member(Object member){if(proxy)return proxy().member(member);  this.put("member", member);return this;};
	 	/** and member is null */
 		public M memberNull(){if(proxy)return proxy().memberNull();if(this.get("memberNot")==null)this.put("memberNot", "");this.put("member", null);return this;};
 		/** not .... */
 		public M memberNot(){if(proxy)return proxy().memberNot();this.put("memberNot", "not");return this;};
 		public M memberNotNull(){if(proxy)return proxy().memberNotNull();this.put("memberNot", "not");this.put("member", null);return this;};
 		public M memberNot(Object member){if(proxy)return proxy().memberNot(member);this.put("memberNot", "not");this.put("member", member);return this;};
	 		
			
		public M memberIn(String ids){
			if(proxy)return proxy().memberIn(ids);  this.put("memberIn", ids);return this;
		};	
 			
		
			
	 	
			
		public M commodity$on(Commodity.M value){if(proxy)return proxy().commodity$on(value);this.put("Commodity", value);value.put("on", "commodity");return this;};
 				
 			
		
		/** 商品信息  [Commodity]      **/
		public M commodity(Object commodity){if(proxy)return proxy().commodity(commodity);  this.put("commodity", commodity);return this;};
	 	/** and commodity is null */
 		public M commodityNull(){if(proxy)return proxy().commodityNull();if(this.get("commodityNot")==null)this.put("commodityNot", "");this.put("commodity", null);return this;};
 		/** not .... */
 		public M commodityNot(){if(proxy)return proxy().commodityNot();this.put("commodityNot", "not");return this;};
 		public M commodityNotNull(){if(proxy)return proxy().commodityNotNull();this.put("commodityNot", "not");this.put("commodity", null);return this;};
 		public M commodityNot(Object commodity){if(proxy)return proxy().commodityNot(commodity);this.put("commodityNot", "not");this.put("commodity", commodity);return this;};
	 		
		/** and commodity <= ? */
		public M commodityMin(Object min){if(proxy)return proxy().commodityMin(min);this.put("commodityMin", min);return this;};
		/** and commodity >= ? */
		public M commodityMax(Object max){if(proxy)return proxy().commodityMax(max);this.put("commodityMax", max);return this;};
			
			
		public M commodityIn(String ids){
			if(proxy)return proxy().commodityIn(ids);  this.put("commodityIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 价格        **/
		public M pPrice(Object pPrice){if(proxy)return proxy().pPrice(pPrice);  this.put("pPrice", pPrice);return this;};
	 	/** and p_price is null */
 		public M pPriceNull(){if(proxy)return proxy().pPriceNull();if(this.get("pPriceNot")==null)this.put("pPriceNot", "");this.put("pPrice", null);return this;};
 		/** not .... */
 		public M pPriceNot(){if(proxy)return proxy().pPriceNot();this.put("pPriceNot", "not");return this;};
 		public M pPriceNotNull(){if(proxy)return proxy().pPriceNotNull();this.put("pPriceNot", "not");this.put("pPrice", null);return this;};
 		public M pPriceNot(Object pPrice){if(proxy)return proxy().pPriceNot(pPrice);this.put("pPriceNot", "not");this.put("pPrice", pPrice);return this;};
	 		
		/** and p_price <= ? */
		public M pPriceMin(Object min){if(proxy)return proxy().pPriceMin(min);this.put("pPriceMin", min);return this;};
		/** and p_price >= ? */
		public M pPriceMax(Object max){if(proxy)return proxy().pPriceMax(max);this.put("pPriceMax", max);return this;};
			
			
		
			
	 	
			
		
		/** 单位        **/
		public M pUnit(Object pUnit){if(proxy)return proxy().pUnit(pUnit);  this.put("pUnit", pUnit);return this;};
	 	/** and p_unit is null */
 		public M pUnitNull(){if(proxy)return proxy().pUnitNull();if(this.get("pUnitNot")==null)this.put("pUnitNot", "");this.put("pUnit", null);return this;};
 		/** not .... */
 		public M pUnitNot(){if(proxy)return proxy().pUnitNot();this.put("pUnitNot", "not");return this;};
 		public M pUnitNotNull(){if(proxy)return proxy().pUnitNotNull();this.put("pUnitNot", "not");this.put("pUnit", null);return this;};
 		public M pUnitNot(Object pUnit){if(proxy)return proxy().pUnitNot(pUnit);this.put("pUnitNot", "not");this.put("pUnit", pUnit);return this;};
	 		
			
		
			
	 	
			
		
		/** 商品图        **/
		public M img(Object img){if(proxy)return proxy().img(img);  this.put("img", img);return this;};
	 	/** and img is null */
 		public M imgNull(){if(proxy)return proxy().imgNull();if(this.get("imgNot")==null)this.put("imgNot", "");this.put("img", null);return this;};
 		/** not .... */
 		public M imgNot(){if(proxy)return proxy().imgNot();this.put("imgNot", "not");return this;};
 		public M imgNotNull(){if(proxy)return proxy().imgNotNull();this.put("imgNot", "not");this.put("img", null);return this;};
 		public M imgNot(Object img){if(proxy)return proxy().imgNot(img);this.put("imgNot", "not");this.put("img", img);return this;};
	 		
			
		
			
	 	
			
		
		/** 数量        **/
		public M number(Object number){if(proxy)return proxy().number(number);  this.put("number", number);return this;};
	 	/** and number is null */
 		public M numberNull(){if(proxy)return proxy().numberNull();if(this.get("numberNot")==null)this.put("numberNot", "");this.put("number", null);return this;};
 		/** not .... */
 		public M numberNot(){if(proxy)return proxy().numberNot();this.put("numberNot", "not");return this;};
 		public M numberNotNull(){if(proxy)return proxy().numberNotNull();this.put("numberNot", "not");this.put("number", null);return this;};
 		public M numberNot(Object number){if(proxy)return proxy().numberNot(number);this.put("numberNot", "not");this.put("number", number);return this;};
	 		
		/** and number <= ? */
		public M numberMin(Object min){if(proxy)return proxy().numberMin(min);this.put("numberMin", min);return this;};
		/** and number >= ? */
		public M numberMax(Object max){if(proxy)return proxy().numberMax(max);this.put("numberMax", max);return this;};
			
			
		public M numberIn(String ids){
			if(proxy)return proxy().numberIn(ids);  this.put("numberIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 限制        **/
		public M pLimit(Object pLimit){if(proxy)return proxy().pLimit(pLimit);  this.put("pLimit", pLimit);return this;};
	 	/** and p_limit is null */
 		public M pLimitNull(){if(proxy)return proxy().pLimitNull();if(this.get("pLimitNot")==null)this.put("pLimitNot", "");this.put("pLimit", null);return this;};
 		/** not .... */
 		public M pLimitNot(){if(proxy)return proxy().pLimitNot();this.put("pLimitNot", "not");return this;};
 		public M pLimitNotNull(){if(proxy)return proxy().pLimitNotNull();this.put("pLimitNot", "not");this.put("pLimit", null);return this;};
 		public M pLimitNot(Object pLimit){if(proxy)return proxy().pLimitNot(pLimit);this.put("pLimitNot", "not");this.put("pLimit", pLimit);return this;};
	 		
		/** and p_limit <= ? */
		public M pLimitMin(Object min){if(proxy)return proxy().pLimitMin(min);this.put("pLimitMin", min);return this;};
		/** and p_limit >= ? */
		public M pLimitMax(Object max){if(proxy)return proxy().pLimitMax(max);this.put("pLimitMax", max);return this;};
			
			
		public M pLimitIn(String ids){
			if(proxy)return proxy().pLimitIn(ids);  this.put("pLimitIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 规格属性        **/
		public M attribute(Object attribute){if(proxy)return proxy().attribute(attribute);  this.put("attribute", attribute);return this;};
	 	/** and attribute is null */
 		public M attributeNull(){if(proxy)return proxy().attributeNull();if(this.get("attributeNot")==null)this.put("attributeNot", "");this.put("attribute", null);return this;};
 		/** not .... */
 		public M attributeNot(){if(proxy)return proxy().attributeNot();this.put("attributeNot", "not");return this;};
 		public M attributeNotNull(){if(proxy)return proxy().attributeNotNull();this.put("attributeNot", "not");this.put("attribute", null);return this;};
 		public M attributeNot(Object attribute){if(proxy)return proxy().attributeNot(attribute);this.put("attributeNot", "not");this.put("attribute", attribute);return this;};
	 		
			
		
			
	 	
			
		
		/** 预留字段        **/
		public M count(Object count){if(proxy)return proxy().count(count);  this.put("count", count);return this;};
	 	/** and count is null */
 		public M countNull(){if(proxy)return proxy().countNull();if(this.get("countNot")==null)this.put("countNot", "");this.put("count", null);return this;};
 		/** not .... */
 		public M countNot(){if(proxy)return proxy().countNot();this.put("countNot", "not");return this;};
 		public M countNotNull(){if(proxy)return proxy().countNotNull();this.put("countNot", "not");this.put("count", null);return this;};
 		public M countNot(Object count){if(proxy)return proxy().countNot(count);this.put("countNot", "not");this.put("count", count);return this;};
	 		
		/** and count <= ? */
		public M countMin(Object min){if(proxy)return proxy().countMin(min);this.put("countMin", min);return this;};
		/** and count >= ? */
		public M countMax(Object max){if(proxy)return proxy().countMax(max);this.put("countMax", max);return this;};
			
			
		public M countIn(String ids){
			if(proxy)return proxy().countIn(ids);  this.put("countIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 来源描述        **/
		public M descr(Object descr){if(proxy)return proxy().descr(descr);  this.put("descr", descr);return this;};
	 	/** and descr is null */
 		public M descrNull(){if(proxy)return proxy().descrNull();if(this.get("descrNot")==null)this.put("descrNot", "");this.put("descr", null);return this;};
 		/** not .... */
 		public M descrNot(){if(proxy)return proxy().descrNot();this.put("descrNot", "not");return this;};
 		public M descrNotNull(){if(proxy)return proxy().descrNotNull();this.put("descrNot", "not");this.put("descr", null);return this;};
 		public M descrNot(Object descr){if(proxy)return proxy().descrNot(descr);this.put("descrNot", "not");this.put("descr", descr);return this;};
	 		
			
		
			
	 	
			
		
		/** 有效期        **/
		public M pTermValidity(Object pTermValidity){if(proxy)return proxy().pTermValidity(pTermValidity);  this.put("pTermValidity", pTermValidity);return this;};
	 	/** and p_term_validity is null */
 		public M pTermValidityNull(){if(proxy)return proxy().pTermValidityNull();if(this.get("pTermValidityNot")==null)this.put("pTermValidityNot", "");this.put("pTermValidity", null);return this;};
 		/** not .... */
 		public M pTermValidityNot(){if(proxy)return proxy().pTermValidityNot();this.put("pTermValidityNot", "not");return this;};
 		public M pTermValidityNotNull(){if(proxy)return proxy().pTermValidityNotNull();this.put("pTermValidityNot", "not");this.put("pTermValidity", null);return this;};
 		public M pTermValidityNot(Object pTermValidity){if(proxy)return proxy().pTermValidityNot(pTermValidity);this.put("pTermValidityNot", "not");this.put("pTermValidity", pTermValidity);return this;};
	 		
 		/** and p_term_validity >= ? */
 		public M pTermValidityStart(Object start){if(proxy)return proxy().pTermValidityStart(start);this.put("pTermValidityStart", start);return this;};			
 		/** and p_term_validity <= ? */
 		public M pTermValidityEnd(Object end){if(proxy)return proxy().pTermValidityEnd(end);this.put("pTermValidityEnd", end);return this;};
			
			
		
			
	 	
			
		
		/** 修改时间 [非空]       **/
		public M updateTime(Object updateTime){if(proxy)return proxy().updateTime(updateTime);  this.put("updateTime", updateTime);return this;};
	 	/** and update_time is null */
 		public M updateTimeNull(){if(proxy)return proxy().updateTimeNull();if(this.get("updateTimeNot")==null)this.put("updateTimeNot", "");this.put("updateTime", null);return this;};
 		/** not .... */
 		public M updateTimeNot(){if(proxy)return proxy().updateTimeNot();this.put("updateTimeNot", "not");return this;};
 		public M updateTimeNotNull(){if(proxy)return proxy().updateTimeNotNull();this.put("updateTimeNot", "not");this.put("updateTime", null);return this;};
 		public M updateTimeNot(Object updateTime){if(proxy)return proxy().updateTimeNot(updateTime);this.put("updateTimeNot", "not");this.put("updateTime", updateTime);return this;};
	 		
 		/** and update_time >= ? */
 		public M updateTimeStart(Object start){if(proxy)return proxy().updateTimeStart(start);this.put("updateTimeStart", start);return this;};			
 		/** and update_time <= ? */
 		public M updateTimeEnd(Object end){if(proxy)return proxy().updateTimeEnd(end);this.put("updateTimeEnd", end);return this;};
			
			
		
			
	 	
			
		
		/** 添加时间 [非空]       **/
		public M addTime(Object addTime){if(proxy)return proxy().addTime(addTime);  this.put("addTime", addTime);return this;};
	 	/** and add_time is null */
 		public M addTimeNull(){if(proxy)return proxy().addTimeNull();if(this.get("addTimeNot")==null)this.put("addTimeNot", "");this.put("addTime", null);return this;};
 		/** not .... */
 		public M addTimeNot(){if(proxy)return proxy().addTimeNot();this.put("addTimeNot", "not");return this;};
 		public M addTimeNotNull(){if(proxy)return proxy().addTimeNotNull();this.put("addTimeNot", "not");this.put("addTime", null);return this;};
 		public M addTimeNot(Object addTime){if(proxy)return proxy().addTimeNot(addTime);this.put("addTimeNot", "not");this.put("addTime", addTime);return this;};
	 		
 		/** and add_time >= ? */
 		public M addTimeStart(Object start){if(proxy)return proxy().addTimeStart(start);this.put("addTimeStart", start);return this;};			
 		/** and add_time <= ? */
 		public M addTimeEnd(Object end){if(proxy)return proxy().addTimeEnd(end);this.put("addTimeEnd", end);return this;};
			
			
		
			
	 	
			
		
		/** 状态 [非空]   1:正常 0:无效     **/
		public M status(Object status){if(proxy)return proxy().status(status);  this.put("status", status);return this;};
	 	/** and status is null */
 		public M statusNull(){if(proxy)return proxy().statusNull();if(this.get("statusNot")==null)this.put("statusNot", "");this.put("status", null);return this;};
 		/** not .... */
 		public M statusNot(){if(proxy)return proxy().statusNot();this.put("statusNot", "not");return this;};
 		public M statusNotNull(){if(proxy)return proxy().statusNotNull();this.put("statusNot", "not");this.put("status", null);return this;};
 		public M statusNot(Object status){if(proxy)return proxy().statusNot(status);this.put("statusNot", "not");this.put("status", status);return this;};
	 		
			
		public M statusIn(String ids){
			if(proxy)return proxy().statusIn(ids);  this.put("statusIn", ids);return this;
		};	
 			
		
			
	 	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	
	 	/** 获取所有产品余额 **/
		public @api List<Product> list(Integer size){			
			return getProductList(this,size);
		}
		/** 获取产品余额分页 **/
		public @api Page<Product> page(Integer page,Integer size){			
			return getProductPage(page, size , this);
		}
		/** 根据查询条件取产品余额 **/
		public @api Product get(){			
			return getProduct(this);
		}
		/** 获取产品余额数 **/
		public @api Long count(){			
			return getProductCount(this);
		}
		/** 获取产品余额表达式 **/
		public @api <T> T eval(String strEval){			
			return getProductEval(strEval,this);
		}
		
		/** 获取产品余额统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getProductStats(this,sumKey,groupKey,dateType);
		}
		/** 获取产品余额统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getProductStats(this,sumKey,groupKey,-1);
		}
		
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateProduct(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteProduct(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		
			
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String id="id";
	 			
			
	 	
			
		/** 商品名 [非空]       **/
		public final static @type(String.class) @like String name="name";
	 			
			
	 	
			
		/** 品牌信息  [Merchant]      **/
		public final static @type(Long.class)  String merchant="merchant";
	 			
			
	 	
			
		/** 用户编号 [非空]       **/
		public final static @type(String.class) @like String uid="uid";
	 			
			
	 	
			
		/** 会员名称        **/
		public final static @type(String.class) @like String nickName="nickName";
	 			
			
	 	
			
		/** 所属会员  [Member]      **/
		public final static @type(Long.class)  String member="member";
	 			
			
	 	
			
		/** 商品信息  [Commodity]      **/
		public final static @type(Long.class)  String commodity="commodity";
	 			
		/** and commodity >= ? */
		public final static @type(Long.class) String commodityMin="commodityMin";
		/** and commodity <= ? */
		public final static @type(Long.class) String commodityMax="commodityMax";
				
			
	 	
			
		/** 价格        **/
		public final static @type(Double.class)  String pPrice="pPrice";
	 			
		/** and p_price >= ? */
		public final static @type(Double.class) String pPriceMin="pPriceMin";
		/** and p_price <= ? */
		public final static @type(Double.class) String pPriceMax="pPriceMax";
				
			
	 	
			
		/** 单位        **/
		public final static @type(String.class)  String pUnit="pUnit";
	 			
			
	 	
			
		/** 商品图        **/
		public final static @type(String.class)  String img="img";
	 			
			
	 	
			
		/** 数量        **/
		public final static @type(Integer.class)  String number="number";
	 			
		/** and number >= ? */
		public final static @type(Integer.class) String numberMin="numberMin";
		/** and number <= ? */
		public final static @type(Integer.class) String numberMax="numberMax";
				
			
	 	
			
		/** 限制        **/
		public final static @type(Integer.class)  String pLimit="pLimit";
	 			
		/** and p_limit >= ? */
		public final static @type(Integer.class) String pLimitMin="pLimitMin";
		/** and p_limit <= ? */
		public final static @type(Integer.class) String pLimitMax="pLimitMax";
				
			
	 	
			
		/** 规格属性        **/
		public final static @type(String.class) @like String attribute="attribute";
	 			
			
	 	
			
		/** 预留字段        **/
		public final static @type(Integer.class)  String count="count";
	 			
		/** and count >= ? */
		public final static @type(Integer.class) String countMin="countMin";
		/** and count <= ? */
		public final static @type(Integer.class) String countMax="countMax";
				
			
	 	
			
		/** 来源描述        **/
		public final static @type(String.class) @like String descr="descr";
	 			
			
	 	
			
		/** 有效期        **/
		public final static @type(Date.class)  String pTermValidity="pTermValidity";
	 			
	 	/** and p_term_validity >= ? */
 		public final static @type(Date.class) String pTermValidityStart="pTermValidityStart";
 		/** and p_term_validity <= ? */
 		public final static @type(Date.class) String pTermValidityEnd="pTermValidityEnd";
				
			
	 	
			
		/** 修改时间 [非空]       **/
		public final static @type(Date.class)  String updateTime="updateTime";
	 			
	 	/** and update_time >= ? */
 		public final static @type(Date.class) String updateTimeStart="updateTimeStart";
 		/** and update_time <= ? */
 		public final static @type(Date.class) String updateTimeEnd="updateTimeEnd";
				
			
	 	
			
		/** 添加时间 [非空]       **/
		public final static @type(Date.class)  String addTime="addTime";
	 			
	 	/** and add_time >= ? */
 		public final static @type(Date.class) String addTimeStart="addTimeStart";
 		/** and add_time <= ? */
 		public final static @type(Date.class) String addTimeEnd="addTimeEnd";
				
			
	 	
			
		/** 状态 [非空]   1:正常 0:无效     **/
		public final static @type(Short.class)  String status="status";
	 			
			
	 	
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/** 对象的数据库字段描述 **/
	public static enum C{
		
		id("id"),
		name("name"),
		merchant("merchant"),
		uid("uid"),
		nickName("nick_name"),
		member("member"),
		commodity("commodity"),
		pPrice("p_price"),
		pUnit("p_unit"),
		img("img"),
		number("number"),
		pLimit("p_limit"),
		attribute("attribute"),
		count("count"),
		descr("descr"),
		pTermValidity("p_term_validity"),
		updateTime("update_time"),
		addTime("add_time"),
		status("status"),
		;
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	
	/**
	* 获取产品余额数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = Product.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = Product.getProduct(params);
			else
				value = Product.getProductList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  Product.where().id(param).get();
		else if(!Utils.empty(param.toString()))
			value = Product.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		return toJSON(simple,0);
	}
	public Map toJSON(boolean simple,int step){
		Map map = new HashMap();
		map.put("id",this.getId());
	
		Utils.fms(map,simple?"":"id",this.getId(),this.getId$());
		
			
 		
	
		Utils.fms(map,simple?"":"name",this.getName(),this.getName$());
		
			
 		
	
		Utils.fms(map,simple?"":"merchant",this.getMerchant(),this.getMerchant$());
		
			
 		
	
		Utils.fms(map,simple?"":"uid",this.getUid(),this.getUid$());
		
			
 		
	
		Utils.fms(map,simple?"name":"nickName",this.getNickName(),this.getNickName$());
		
			
 		
	
		Utils.fms(map,simple?"":"member",this.getMember(),this.getMember$());
		
			
 		
	
		Utils.fms(map,simple?"":"commodity",this.getCommodity(),this.getCommodity$());
		
			
 		
	
		Utils.fms(map,simple?"price":"pPrice",this.getpPrice(),this.getpPrice$());
		
			
 		
	
		Utils.fms(map,simple?"unit":"pUnit",this.getpUnit(),this.getpUnit$());
		
			
 		
	
		Utils.fms(map,simple?"":"img",this.getImg(),this.getImg$());
		
			
 		
	
		Utils.fms(map,simple?"":"number",this.getNumber(),this.getNumber$());
		
			
 		
	
		Utils.fms(map,simple?"limit":"pLimit",this.getpLimit(),this.getpLimit$());
		
			
 		
	
		Utils.fms(map,simple?"":"attribute",this.getAttribute(),this.getAttribute$());
		
			
 		
	
		Utils.fms(map,simple?"":"count",this.getCount(),this.getCount$());
		
			
 		
	
		Utils.fms(map,simple?"":"descr",this.getDescr(),this.getDescr$());
		
			
 		
	
		Utils.fms(map,simple?"termValidity":"pTermValidity",this.getpTermValidity(),this.getpTermValidity$());
		
			
 		
	
		Utils.fms(map,simple?"time":"updateTime",this.getUpdateTime(),this.getUpdateTime$());
		
			
 		
	
		Utils.fms(map,simple?"time":"addTime",this.getAddTime(),this.getAddTime$());
		
			
 		
	
		Utils.fms(map,simple?"":"status",this.getStatus(),this.getStatus$());
		
			
 		
	
		if(this.suffix!=null)map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
	
		map.put("id",this.getId());
 		
	
		map.put("name",this.getName());
 		
	
		map.put("merchant",this.getMerchant());
 		
	
		map.put("uid",this.getUid());
 		
	
		map.put("nickName",this.getNickName());
 		
	
		map.put("member",this.getMember());
 		
	
		map.put("commodity",this.getCommodity());
 		
	
		map.put("pPrice",this.getpPrice());
 		
	
		map.put("pUnit",this.getpUnit());
 		
	
		map.put("img",this.getImg());
 		
	
		map.put("number",this.getNumber());
 		
	
		map.put("pLimit",this.getpLimit());
 		
	
		map.put("attribute",this.getAttribute());
 		
	
		map.put("count",this.getCount());
 		
	
		map.put("descr",this.getDescr());
 		
	
		map.put("pTermValidity",this.getpTermValidity());
 		
	
		map.put("updateTime",this.getUpdateTime());
 		
	
		map.put("addTime",this.getAddTime());
 		
	
		map.put("status",this.getStatus());
 		
	
		map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static Product fromMap(Map map){
		Product product = new Product();
	
		product.id = Utils.parseLong(map.get("id"));
 		
	
		product.name = Utils.parseString(map.get("name"));
 		
	
		product.merchant = Utils.parseLong(map.get("merchant"));
 		
	
		product.uid = Utils.parseString(map.get("uid"));
 		
	
	
		product.member = Utils.parseLong(map.get("member"));
 		
	
		product.commodity = Utils.parseLong(map.get("commodity"));
 		
	
		product.pPrice = Utils.parseDouble(map.get("pPrice"));
 		
	
		product.pUnit = Utils.parseString(map.get("pUnit"));
 		
	
		product.img = Utils.parseString(map.get("img"));
 		
	
		product.number = Utils.parseInteger(map.get("number"));
 		
	
		product.pLimit = Utils.parseInteger(map.get("pLimit"));
 		
	
		product.attribute = Utils.parseString(map.get("attribute"));
 		
	
		product.count = Utils.parseInteger(map.get("count"));
 		
	
		product.descr = Utils.parseString(map.get("descr"));
 		
	
		product.pTermValidity = Utils.parseDate(map.get("pTermValidity"));
 		
	
		product.updateTime = Utils.parseDate(map.get("updateTime"));
 		
	
		product.addTime = Utils.parseDate(map.get("addTime"));
 		
	
		product.status = Utils.parseShort(map.get("status"));
 		
	
		return product;
	}
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(Product old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	
	
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	
	public static String getIcon(){
		return "/images/icons/20088256422681277805.png";
	}
	public static String getIconfont(){
		return "icon-lifangtilitiduomiantifangkuai";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,Product.M params){
		if(params==null)params=new Product.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/products/product.edit.html?";
		if(params.get("id")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("id"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/products/product.html?1=1";
		
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		
		
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.id(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(Product.ACT act,Product.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",Product.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(Product.ACT act,Product.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",Product.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.IProductDao getProductDao(){
		return Utils.getBean("productDao");
	};
	
}